import {
	baseUrl
} from './config.js'
//  返回一个promise，
export const topList = () =>
	new Promise((reslove, reject) => {
		let listIds = ['19723756','3779629','2884035','3778678']
		uni.request({
			url: `${baseUrl}/toplist/detail`,
			method: 'GET',
			data: {},
			success: res => {
				let {
					data
				} = res
				const list = data.list.splice(0, 4);

				for (var i = 0; i < listIds.length; i++) {
					list[i].listId = listIds[i]
				
				}
				// console.log(list)
				reslove(list)
			},
			fail: () => {},
			complete: () => {}
		})
	});

//获取歌单列表
export const list =(listId)=>{
	return uni.request({
		url:`${baseUrl}/playlist/detail?id=${listId}`,
		method:'GET',
		
	})
	console.log(listId)
}

//获取  列表
export const songDetail =(songId)=>{
	return uni.request({
		url:`${baseUrl}/song/detail?ids=${songId}`,
		method:'GET',
		
	})
	console.log(listId)
}
//获取  列表
export const songSimi =(songId)=>{
	return uni.request({
		url:`${baseUrl}/simi/song?id=${songId}`,
		method:'GET',
		
	})
	console.log(listId)
}
//获取  列表
export const songComment =(songId)=>{
	return uni.request({
		url:`${baseUrl}/comment/music/?id=${songId}`,
		method:'GET',
		
	})
	console.log(listId)
}

//获取  列表
export const songLyric =(songId)=>{
	return uni.request({
		url:`${baseUrl}/lyric/?id=${songId}`,
		method:'GET',
		
	})
	console.log(listId)
}

//获取  列表
export const songUrl =(songId)=>{
	return uni.request({
		url:`${baseUrl}/song/url?id=${songId}`,
		method:'GET',
		
	})
	// console.log(listId)
}

//http://localhost:3000/search/hot/detail

export function searchHot(){
	return uni.request({
		url: `${baseUrl}/search/hot/detail`,
		method: 'GET'
	});
}

//http://localhost:3000/search?keywords=少年

export function searchWord(word){
	return uni.request({
		url: `${baseUrl}/search?keywords=${word}`,
		method: 'GET'
	});
}

//http://localhost:3000/search/suggest?keywords=少年&type=mobile

export function searchSuggest(word){
	return uni.request({
		url: `${baseUrl}/search/suggest?keywords=${word}&type=mobile`,
		method: 'GET'
	});
}